package 模板_一维前缀和;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        int len = n + 1;
        int[] arr = new int[len];
        long[] dp = new long[len];
        for (int i = 1; i < len; i++) {
            arr[i] = in.nextInt();
            dp[i] = dp[i - 1] + (long)arr[i];
        }
        while (q > 0) {
            int l = in.nextInt();
            int r = in.nextInt();
            System.out.println(dp[r] - dp[l - 1]);
            q--;
        }
    }
}